
#ifndef _DIGRAPH_H_
#define _DIGRAPH_H_

#include <iostream.h>
#include <string.h>

#include <Element.h>

typedef struct tagLink {
	Element symbol;
	Element link;
	struct tagLink* next;
} Link;

typedef struct tagMainNode {
	Element element;
	int numLinks;
	struct tagLink* links;
} MainNode;

class Digraph {
private :
	int added, num;
	MainNode* main;

	Link* allocLink(Element symbol, Element link);

public :
	Digraph();
	Digraph(int numElements);

	void create(int numElements);

	void add(Element elem);
	void add(Element elem, Element symbol, Element link);

	int ifExists(Element elem);
	int ifExists(Element elem, Element symbol);
	Element* getSymbols(Element elem, int& numSym);
	Element getLink(Element elem, Element symbol);

	virtual ~Digraph();

	friend ostream& operator<<(ostream& os, const Digraph& dg);
};


#endif // _DIGRAPH_H_

